/*
 * @Author: wwssaabb
 * @Date: 2021-08-18 15:34:35
 * @LastEditTime: 2021-11-17 16:09:17
 * @FilePath: \hospitable-rental-for-react\src\api\index.js
 */

import ajax from './ajax'
import axios from 'axios'

// export const BASEURL = 'http://localhost:8080' //请求图片地址服务器
export const BASEURL = 'http://8.129.105.10:8890' //请求图片地址服务器

//获取首页轮播图
export const reqSwiper = () => ajax('/home/swiper')

//获取租房小组
export const reqGroups = (params) => ajax('/home/groups', {
  params
})

//获取资讯列表
export const reqNews = (params) => ajax('/home/news', {
  params
})

//获取和查询房子
export const reqHouses = (params) => ajax('/houses', params)

//获取查询房子的条件
export const reqHousesCondition = (params) => ajax('/houses/condition', params)

//获取城市列表
export const reqCityList = (params) => ajax('/area/city', params)

//获取热门城市列表
export const reqCityHot = () => ajax('/area/hot')

//获取当前地理位置
export const reqCurrentCityName = () => axios.get('https://restapi.amap.com/v3/ip?key=cee0160bebaf18f246314382d678939a')

//获取城市信息
export const reqCityInfo = (params) => ajax('/area/info', params)

//获取地图房源信息
export const reqMapData = (params) => ajax('/area/map', params)

//小区关键词搜索
export const reqCommunityData = (params) => ajax('/area/community', params)

//获取房屋的详细信息
export const reqHouseDetail = (id) => ajax('/houses/' + id)

//用户登录
export const reqUserLogin = (params) => ajax('/user/login', params, 'POST')

//用户登出
export const reqUserLogout = () => ajax('/user/logout', {}, 'POST')

//获取用户资料
export const reqUserData = () => ajax('/user')

//修改用户资料
export const reqUpdateUserData = (params) => ajax('/user', params, 'PATCH')

//用户注册
export const reqUserRegister = (params) => ajax('/user/registered', params, 'POST')

//房源添加收藏
export const reqAddCollected = (id) => ajax('/user/favorites/' + id, {}, 'POST')

//房源是否已收藏
export const reqCheckIsCollected = (id) => ajax('/user/favorites/' + id)

//删除房源的收藏
export const reqDeleteCollected = (id) => ajax('/user/favorites/' + id, {}, 'DELETE')

//获取收藏列表
export const reqCollectedList = () => ajax('/user/favorites/')

//房屋图片上传
export const reqHouseImgUpload = (file, headers) => ajax('/houses/image', file, 'POST', headers)

//发布房源
export const reqHousePublish = (params) => ajax('/user/houses', params, 'POST')

//获取已的发布房源列表
export const reqGetHousePublishList = () => ajax('/user/houses')